# coding:utf-8
from PIL import Image
import pytesseract

# img = Image.open("/Users/stevez/workspace/pycharmSpace/scrapyExercise/files/ocr_images/past.png")
# print(pytesseract.image_to_string(img))

img = Image.open("/Users/stevez/workspace/pycharmSpace/scrapyExercise/files/ocr_images/past.png")
gray = img.convert("L")
gray.save("captcha_gray.png")
bw = gray.point(lambda x:0 if x<1 else 255, "1")
bw.save("captcha_thresholded.png")
print(pytesseract.image_to_string(bw))
